package com.imrookie.gendoc.apiword.template;

import com.imrookie.wrap.ClassWrap;
import com.imrookie.wrap.FieldWrap;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangjiyu@imdada.cn
 * @create 2018/12/29
 */
public class ApiClassTemplate {
    private int no;
    private String className;
    private List<ApiFieldTemplate> fieldList;

    public ApiClassTemplate() {
    }

    public ApiClassTemplate(int no, ClassWrap classWrap) {
        this.no = no;
        this.className = classWrap.getWholeClassName();
        if (classWrap.getFieldWraps() != null && classWrap.getFieldWraps().length > 0) {
            List<ApiFieldTemplate> list = new ArrayList<ApiFieldTemplate>(classWrap.getFieldWraps().length);
            int i = 1;
            for (FieldWrap fieldWrap : classWrap.getFieldWraps()) {
                list.add(new ApiFieldTemplate(i++, fieldWrap));
            }
            this.fieldList = list;
        }
    }
    public ApiClassTemplate(ClassWrap classWrap) {
        this.className = classWrap.getWholeClassName();
        if (classWrap.getFieldWraps() != null && classWrap.getFieldWraps().length > 0) {
            List<ApiFieldTemplate> list = new ArrayList<ApiFieldTemplate>(classWrap.getFieldWraps().length);
            int i = 1;
            for (FieldWrap fieldWrap : classWrap.getFieldWraps()) {
                list.add(new ApiFieldTemplate(i++, fieldWrap));
            }
            this.fieldList = list;
        }
    }

    public int getNo() {
        return no;
    }

    public void setNo(int no) {
        this.no = no;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public List<ApiFieldTemplate> getFieldList() {
        return fieldList;
    }

    public void setFieldList(List<ApiFieldTemplate> fieldList) {
        this.fieldList = fieldList;
    }
}
